{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "文档说明： Automatically created module for IPython interactive environment\n",
      "是否主文件： __main__\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name '__file__' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-385d02765a07>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'文档说明：'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'是否主文件：'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0m__name__\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'文件名：'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m__file__\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name '__file__' is not defined"
     ]
    }
   ],
   "source": [
    "print('文档说明：',__doc__)\n",
    "print('是否主文件：',__name__)\n",
    "print('文件名：', __file__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'> 87985136 -2740400670357623928\n",
      "False\n",
      "Help on built-in function strip:\n",
      "\n",
      "strip(chars=None, /) method of builtins.str instance\n",
      "    Return a copy of the string with leading and trailing whitespace remove.\n",
      "    \n",
      "    If chars is given and not None, remove characters in chars instead.\n",
      "\n",
      "None\n",
      "1267650600228229401496703205376\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "a = 'hello'\n",
    "print(type(a),id(a),hash(a))\n",
    "print(callable(a)) #对象是否可以调用，False说明不可调用\n",
    "\n",
    "print(help(a.strip))\n",
    "exec('print(2**100)') #返回值None\n",
    "print(eval('len(a)')) #表达式的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "变量： {'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"], '_oh': {}, '_dh': ['E:\\\\360disk\\\\python_study\\\\基本语法3'], 'In': ['', \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x0000000002F46448>>, 'exit': <IPython.core.autocall.ZMQExitAutocall object at 0x000000000506A448>, 'quit': <IPython.core.autocall.ZMQExitAutocall object at 0x000000000506A448>, '_': '', '__': '', '___': '', '_i': \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", '_ii': \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", '_iii': '', '_i1': \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", '_i2': \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", 'a': 'hello', '_i3': \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"}\n",
      "局部变量： {'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"], '_oh': {}, '_dh': ['E:\\\\360disk\\\\python_study\\\\基本语法3'], 'In': ['', \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x0000000002F46448>>, 'exit': <IPython.core.autocall.ZMQExitAutocall object at 0x000000000506A448>, 'quit': <IPython.core.autocall.ZMQExitAutocall object at 0x000000000506A448>, '_': '', '__': '', '___': '', '_i': \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", '_ii': \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", '_iii': '', '_i1': \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", '_i2': \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", 'a': 'hello', '_i3': \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"}\n",
      "全局变量： {'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"], '_oh': {}, '_dh': ['E:\\\\360disk\\\\python_study\\\\基本语法3'], 'In': ['', \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x0000000002F46448>>, 'exit': <IPython.core.autocall.ZMQExitAutocall object at 0x000000000506A448>, 'quit': <IPython.core.autocall.ZMQExitAutocall object at 0x000000000506A448>, '_': '', '__': '', '___': '', '_i': \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", '_ii': \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", '_iii': '', '_i1': \"print('文档说明：',__doc__)\\nprint('是否主文件：',__name__)\\nprint('文件名：', __file__)\", '_i2': \"a = 'hello'\\nprint(type(a),id(a),hash(a))\\nprint(callable(a)) #对象是否可以调用，False说明不可调用\\nprint(help(a.strip))\\nexec('print(2**100)') #返回值None\\nprint(eval('len(a)')) #表达式的值\", 'a': 'hello', '_i3': \"print('变量：',vars())\\nprint('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\\nprint('全局变量：',globals())\"}\n"
     ]
    }
   ],
   "source": [
    "print('变量：',vars())\n",
    "print('局部变量：',locals()) #以字典类型返回当前位置的全部局部变量\n",
    "print('全局变量：',globals())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前程序的内容： ['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_i', '_i1', '_i2', '_i3', '_i4', '_ih', '_ii', '_iii', '_oh', 'a', 'exit', 'get_ipython', 'quit']\n",
      "copy模块内容： ['Error', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_copy_dispatch', '_copy_immutable', '_deepcopy_atomic', '_deepcopy_dict', '_deepcopy_dispatch', '_deepcopy_list', '_deepcopy_method', '_deepcopy_tuple', '_keep_alive', '_reconstruct', 'copy', 'deepcopy', 'dispatch_table', 'error']\n"
     ]
    }
   ],
   "source": [
    "print('当前程序的内容：',dir())\n",
    "import copy\n",
    "print('copy模块内容：',dir(copy)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
